home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98b.txt / 000123_icon-group-sender _Tue Jul 7 17:00:37 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  1KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.8/8.8.7) with SMTP id RAA03697
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Tue, 7 Jul 1998 17:00:36 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA08522; Tue, 7 Jul 1998 17:00:23 -0700
  7. Message-Id: <35A2750A.E12A0673@aasaa.ofe.org>
  8. Date: Tue, 07 Jul 1998 13:20:42 -0600
  9. From: David Starner <dstarner98@aasaa.ofe.org>
  10. X-Mailer: Mozilla 4.05 [en] (Win95; I)
  11. Mime-Version: 1.0
  12. To: icon-group@optima.CS.Arizona.EDU
  13. Subject: Stripping excessive spaces
  14. Content-Type: text/plain; charset=us-ascii
  15. Content-Transfer-Encoding: 7bit
  16. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  17. Status: RO
  18. Content-Length: 549
  19.  
  20. I've just started programming in Icon, and I came across the problem of
  21. removing all the starting and ending spaces from a string. This was my
  22. solution, but I think it's terribly inefficent. Can some one help me
  23. with a better way to do this?
  24.  
  25. procedure clip(s1)
  26.     if type(s1) == "null" then fail
  27.     s1 ?:= {
  28.         tab(many(' ')) & tab(0)
  29.         }
  30.     s1 := reverse(s1)
  31.     s1 ?:= {
  32.         tab(many(' ')) & tab(0)
  33.         }
  34.     s1 := reverse(s1)
  35.     return s1
  36. end
  37. -- 
  38. David Starner - dvdeug@hotmail.com, dstarner98@aasaa.ofe.org
  39. GURPS: http://www.geocities.com/TimesSquare/Ring/7895/
  40.